package com.snowy.framework.db.mybatis;

import com.baomidou.mybatisplus.extension.plugins.OptimisticLockerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * 注册乐观锁 version版本
 * 不要再加where version = xxx条件，也不需要手动给version +
 * @Author cl
 * @Date 2020.10.30
 */
@EnableTransactionManagement
@Configuration
public class VersionRegistLockInterceptor {

    /**
     * 注册乐观锁
     * @return
     */
    @Bean
    public OptimisticLockerInterceptor optimisticLockerInterceptor() {
        return new OptimisticLockerInterceptor();
    }
}
